import 'package:animal/constant/index_constant.dart';
import 'package:animal/ui/friend/controller/search_friend_controller.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/appbar_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

///搜索好友
class SearchFriendPage extends StatelessWidget {
  SearchFriendPage({Key? key}) : super(key: key);
  late SearchFriendController controller;

  @override
  Widget build(BuildContext context) {
    controller = Get.put(SearchFriendController());
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBarWidget.defaultAppBar(title: const Text("搜索好友"), backgroundColor: Colors.white, elevation: 0),
      body: Column(
        children: [
          Container(
            alignment: Alignment.centerLeft,
            height: ScreenUtil().L(36),
            margin: EdgeInsets.symmetric(horizontal: ScreenUtil().L(16)),
            padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(14)),
            decoration: BoxDecoration(color: KColorConstant.textFieldBgColor, borderRadius: BorderRadius.circular(ScreenUtil().L(20))),
            child: Row(
              children: [
                Container(margin: EdgeInsets.only(right: ScreenUtil().L(5)), child: Image.asset("icons/icon_search.png", width: ScreenUtil().L(18))),
                Expanded(
                  child: TextField(
                    style: KFontConstant.myTextStyle(size: 17),
                    maxLines: 1,
                    maxLength: 18,
                    controller: controller.controller,
                    decoration: InputDecoration(
                        hintText: "搜索",
                        //添加内部左边图标
                        prefixIconConstraints: const BoxConstraints(
                            //添加内部图标之后，图标和文字会有间距，实现这个方法，不用写任何参数即可解决
                            ),
                        isCollapsed: true,
                        hintStyle: KFontConstant.myTextStyle(size: 16, color: const Color(0XFFBFC4CC)),
                        border: InputBorder.none,
                        counterText: ""),
                  ),
                ),
                Obx(() => Visibility(
                    visible: controller.showDelete.value,
                    child: InkWell(child: const Icon(Icons.highlight_remove_rounded, color: Colors.black54), onTap: ()=>controller.deleteController())))
              ],
            ),
          )
        ],
      ),
    );
  }
}
